<template>
  <div class="content">数据正在导出，请耐心等待~~~</div>
</template>

<script>
  import {
    userManagement,
    changeCard,
    crmCardListForSpare,
    listForDisabled,
    removeCardList,
    coldCardList,
    crmCardList,
    selectTransactionRecord,
    returnCommissionList,
    realNameCheckList,
    orderManagement,
  } from '@/api/getData'

  export default {
    name: "exlDownload",
    data() {
      return {
        list: [],
        filterVal: [],
        info: {},
      }
    },
    async created() {
      this.info = JSON.parse(this.$route.query.info);
      this.list = JSON.parse(this.$route.query.list);
      this.filterVal = JSON.parse(this.$route.query.filterVal);
      let obj = JSON.parse(this.$route.query.obj);
      let apiName = this.info.api;
      this.getList(apiName, obj);
    },
    methods: {
      getList(api, obj) {
        let a = import("@/api/getData");

        a.then(async v => {
          let req = eval("v." + api);
          let back = await req(obj);
          let data = [];
          // console.log(back._result);
          if(back._result){
            data = back.data.records;
            if(api==='returnCommissionList'){
              for(let item of data){
                item.reduceMoney = parseFloat(item.balance - item.applyMoney).toFixed(2); // 通过后金额
                if (item.dictStatus === 'C_WAIT') {
                  item.reduceMoney = parseFloat(item.balance - item.applyMoney).toFixed(2)
                } else if (item.dictStatus === 'C_REFUSE' || item.dictStatus === 'C_THROUGH') {
                  item.reduceMoney = '-';
                }
              }
            }
          }

          this.$exportToExcel(this.list, this.filterVal, data, this.info.name);
        })
      }
    }
  }
</script>

<style scoped>
  .content {
    width: 100%;
    min-height: 400px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #666;
  }
</style>
